package com.cyw.consumer.hello;

import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author: CYW
 * @Date: 2021/1/3 23:19
 */
@Component//必须加入到spring中
//@Queue参数  (队列名,是否持久化,是否自动删除)
@RabbitListener(queuesToDeclare = @Queue(value = "hello"))
public class HelloConsumer {

    @RabbitHandler//表示此方法是rabbitmq的回调函数
    public void receive(String message){
        System.out.println("message = " + message);
    }
}
